#!/usr/bin/ruby
$:.unshift File.join(File.dirname(__FILE__))
require 'AWS/SQS'
require 'basic_configuration'
require 'aws_context'
require 'pp'

#  Display information about the given queue.

if ARGV[0] == '-?' || ARGV.size != 1 then
  puts "usage: get-queue-info name"
  exit 1
end
name=ARGV[0]

Signal.trap("INT") do
  exit 2
end

config = BasicConfiguration.new
sqs = AwsContext.instance.sqs(*config.keys)
begin
  url = sqs.list_queues(name).first
  if url.nil? 
    puts "queue not found: #{name}"
   exit 1
  else  
    res = sqs.get_queue_attributes(url)
    pp res
  end
rescue
  puts "error #{$!} #{name}"
  exit 1
end

